﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using PrimeFactorLibrary;


namespace PrimeFactorLibrary.Tests
{
    [TestClass]
    public class PrimeFactorCalculatorTests
    {
        private PrimeFactorCalculator calculator;

        [TestInitialize]
        public void Setup()
        {
            calculator = new PrimeFactorCalculator();
        }

        [TestMethod]
        public void GetPrimeFactors_Input4_Returns2Times2()
        {
            // Arrange
            int input = 4;
            string expected = "2 × 2";

            // Act
            string actual = calculator.PrimeFactors(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetPrimeFactors_Input30_Returns5Times3Times2()
        {
            // Arrange
            int input = 30;
            string expected = "5 × 3 × 2";

            // Act
            string actual = calculator.PrimeFactors(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetPrimeFactors_Input1_Returns1()
        {
            // Arrange
            int input = 1;
            string expected = "1";

            // Act
            string actual = calculator.PrimeFactors(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetPrimeFactors_Input997_Returns997()
        {
            // Arrange
            int input = 997; // 997是质数
            string expected = "997";

            // Act
            string actual = calculator.PrimeFactors(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetPrimeFactors_Input1000_Returns5Times5Times5Times2Times2Times2()
        {
            // Arrange
            int input = 1000;
            string expected = "5 × 5 × 5 × 2 × 2 × 2";

            // Act
            string actual = calculator.PrimeFactors(input);

            // Assert
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void GetPrimeFactors_Input0_ThrowsArgumentException()
        {
            // Arrange
            int input = 0;

            // Act
            calculator.PrimeFactors(input);

            // Assert: Expects exception
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void GetPrimeFactors_InputNegative_ThrowsArgumentException()
        {
            // Arrange
            int input = -10;

            // Act
            calculator.PrimeFactors(input);

            // Assert: Expects exception
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void GetPrimeFactors_InputGreaterThan1000_ThrowsArgumentException()
        {
            // Arrange
            int input = 1001;

            // Act
            calculator.PrimeFactors(input);

            // Assert: Expects exception
        }
    }
}
